package com.example.tianyidemo.controller;

import com.example.tianyidemo.pojo.Result;
import com.example.tianyidemo.pojo.User;
import com.example.tianyidemo.service.PersonageupdateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//个人中心修改
@Slf4j
@CrossOrigin//准许跨域请求
@RestController//包含@Controller（三层架构声明控制器）和@ResponseBody（转化json格式）
public class PersonageupdateController {
    @Autowired
    private PersonageupdateService personageupdateService;
    @PostMapping("/updateuser")
    public Result updateUser(@RequestBody User updatedUser) {
        log.info("接收到要更新的用户信息: {}", updatedUser);
        boolean isSuccess = personageupdateService.updateUserData(updatedUser);
        if (isSuccess) {
            return Result.success("用户信息更新成功");
        } else {
            return Result.error("用户信息更新失败");
        }
    }

}
